package com.zzb.DTO;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
public class ResultDTO {
    //状态码
    private Integer code;
    //返回给前端的信息
    private String msg;
    //计数，操作影响的数据条数
    private Integer count;
    //数据
    private Object data;

    public ResultDTO(Integer code, String msg, Integer count, Object data) {
        this.code = code;
        this.msg = msg;
        this.count = count;
        this.data = data;
    }

    public static ResultDTO getResult(String msg) {
        return new ResultDTO(0, msg, 1, null);
    }

    public static ResultDTO getResult(Integer count) {
        return new ResultDTO(0, "", count, null);
    }

    public static ResultDTO getResult(String msg, int count) {
        return new ResultDTO(0, msg, count, null);
    }

    public static ResultDTO getResult(String msg, Object data) {
        return new ResultDTO(0, msg, 1, data);
    }

    public static <T> ResultDTO getResult(int count, List<T> list) {
        return new ResultDTO(0, "", count, list);
    }

    public static ResultDTO getResult(String msg, int count, Object data) {
        return new ResultDTO(0,msg,count,data);
    }

}
